//
// Created by Administrator on 2023/6/3.
//


#include "../header/Open_File_Dialog.h"


Open_File_Dialog::Open_File_Dialog(): LDF_Dialog()
    , row_checkbox(new QCheckBox()), columns_checkbox(new QCheckBox()), open_button(new QPushButton())

{
    this->Control_Profile();
}


Open_File_Dialog::Open_File_Dialog(New_Table* new_table): LDF_Dialog()
    , row_checkbox(new QCheckBox()), columns_checkbox(new QCheckBox()), open_button(new QPushButton())
    , new_table(new_table)
{
    this->Control_Profile();
}


Open_File_Dialog::~Open_File_Dialog()
{
    delete row_checkbox, columns_checkbox, open_button;
}


void Open_File_Dialog::Control_Profile()
{
    this->row_checkbox->setParent(this);
    this->row_checkbox->setText("首行列索引");
    this->row_checkbox->setObjectName("Row_CheckBox");
    this->row_checkbox->setStyleSheet(row_checkbox_qss);
    this->row_checkbox->resize(100, 30);
    this->row_checkbox->move(200, 90);


    this->columns_checkbox->setParent(this);
    this->columns_checkbox->setText("首列行索引");
    this->columns_checkbox->setObjectName("Columns_CheckBox");
    this->columns_checkbox->setStyleSheet(columns_checkbox_qss);
    this->columns_checkbox->resize(100, 30);
    this->columns_checkbox->move(200, 150);


    this->open_button->setParent(this);
    this->open_button->setText("打开CSV文件");
    this->open_button->setObjectName("Open_File_Button");
    this->open_button->setStyleSheet(open_button_qss);
    this->open_button->resize(100, 30);
    this->open_button->move(200, 210);
}


void Open_File_Dialog::Set_Table(New_Table *new_table)
{
    this->new_table = new_table;
}


void Open_File_Dialog::Check_Click()
{
    if(this->row_checkbox->isChecked() && this->columns_checkbox->isChecked())
    {
        this->new_table->Set_Read_Mode(3);
    }
    else if (this->row_checkbox->isChecked())
    {
        this->new_table->Set_Read_Mode(2);
    }
    else if(this->columns_checkbox->isChecked())
    {
        this->new_table->Set_Read_Mode(1);
    }
}

